<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>合并数据完成</title>
</head>

<body>
    <script>
        let obj1 = {
            name: 'haha',
            age: '10',
            items: [{ haha: '1', hello: '2' }]
        }
        let obj2 = {
            name: 'liangzai',
            age: '18',
            items: [{ bananer: '1', apple: '2' }]
        }
        obj1 = {
            ...obj2,
            items: [
                ...obj1.items,
                ...obj2.items
            ]
        }
        obj1 = {
            name: 'liangzai',
            age: '18',
            // items: [{ bananer: '1', apple: '2' }] items如果同名，会被覆盖掉，最后剩下一个
            items: [
                ...obj1.items,
                ...obj2.items
            ]
        }
        console.log(obj1);
    </script>
</body>

</html>